﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using System.IO;
using Newtonsoft.Json;

namespace PruebasDeConcepto
{
    [TestClass]
    public class UnitTest1
    {
        [Ignore]
        [TestMethod]
        public void TestMethod1()
        {
            JObject jObject = JObject.Parse(File.ReadAllText(@"C:\test.json"));
            Console.WriteLine(jObject);
            
            String[] variables = {"Nombre"};
            
            foreach (string variable in variables)
            {
                Console.WriteLine(variable + ": " + jObject[variable].ToString());
                
            }     
            /* String data = @"{
                                Nombre: ""Noel"",
                                Apellido: ""Díaz Rodríguez""
                            }";
            JObject jObject = JObject.Parse(data); 
            string nombre = jObject["Nombre"].ToString();
            string apellido = jObject["Apellido"].ToString(); */

        }


        [TestMethod]
        public void TestMethod2()
        {
            var definition = new { Name = "" };
            string json1 = @"{'Name':'James'}";
            var customer1 = JsonConvert.DeserializeAnonymousType(json1, definition);

            Console.WriteLine(customer1.Name);
            // James

            string json2 = @"{'Name':'Mike'}";
            var customer2 = JsonConvert.DeserializeAnonymousType(json2, definition);

            Console.WriteLine(customer2.Name);
        }

        [TestMethod]
        public void TestLeerJson()
        {
            string json1 = File.ReadAllText(@"D:\Grupo\trunk\MotorIntegracion\PruebasDeConcepto\json1.json");
            var definition = new { palabraID = "", diccionarioID = "" };

            var res = JsonConvert.DeserializeAnonymousType(json1, definition);
            Console.WriteLine(res);
        }
/*

        [TestMethod]
        public void TestMethod1()
        {
            var definition = new { Name = "" };
            string json1 = @"{'Name':'James'}";
            var customer1 = JsonConvert.DeserializeAnonymousType(json1, definition);

            Console.WriteLine(customer1.Name);
            // James

            string json2 = @"{'Name':'Mike'}";
            var customer2 = JsonConvert.DeserializeAnonymousType(json2, definition);

            Console.WriteLine(customer2.Name);
        }

        [TestMethod]
        public void TestLeerJson()
        {
            string json1 = File.ReadAllText(@"D:\Grupo\trunk\MotorIntegracion\PruebasDeConcepto\json1.json");
            var definition = new { palabraID = "", diccionarioID = "" };

            var res = JsonConvert.DeserializeAnonymousType(json1, definition);
            Console.WriteLine(res);
        }
*/
    }
}
